package com.ideaction.entity.func;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;

import java.util.ArrayList;
import java.util.List;

@Getter
@Setter
@Document
public class FuncControll {
    
    @Id
    @JsonProperty("Sid")
    private byte sid;// 1.礼包码2.实名认证
    
    @JsonProperty("Type")
    private byte type;// 0隐藏 1显示
    
    @JsonIgnore
    private List<String> channelList = new ArrayList<>();
    
    @JsonIgnore
    private List<String> versionList = new ArrayList<>();
    
    public boolean hit(String channel, String version) {
        boolean hit = true;
        hit &= channelList.isEmpty() || channelList.contains(channel);
        hit &= versionList.isEmpty() || versionList.contains(version);
        return hit;
    }
}
